package ru.nosport.matrixaria.modules.core.rmreg;

import ru.nosport.matrixaria.modules.common.AppServerProcess;
import ru.nosport.matrixaria.core.ModuleShortcut;
import ru.nosport.matrixaria.core.MessageHandler;
import ru.nosport.matrixaria.core.MessageHandlerException;
import org.apache.commons.configuration.Configuration;

/**
 * User: Victor Fabrichenko
 * Date: 28.04.2009
 * Time: 16:34:16
 */
public class RemoteModuleRegistrationClientApp implements RemoteModuleRegistration, AppServerProcess {

	private String remoteName;

	public RemoteModuleRegistrationClientApp(Configuration _conf){
		this.remoteName = _conf.getString("remoteModuleRegistrationName");
	}

	public boolean registration(ModuleShortcut _module) throws MessageHandlerException {
		return (Boolean)MessageHandler.sendMessage(this.remoteName, "registration", new Object[]{_module});

	}

	public boolean exists(ModuleShortcut _module) throws MessageHandlerException {
		return (Boolean)MessageHandler.sendMessage(this.remoteName, "exists", new Object[]{_module});
	}

	public boolean moduleStart() throws Exception {
		return true;
	}

	public boolean moduleStop() {
		return true;
	}

	public boolean isModuleRunning() {
		return true;
	}

	public String moduleStat() {
		return this.getClass().getName() + " stat";
	}
}
